﻿
namespace SharpDepend.WinRT
{
    public class StopwatchManager : IStopwatchManager
    {
        private static readonly System.Diagnostics.Stopwatch mStopwatch = new System.Diagnostics.Stopwatch();

        static StopwatchManager()
        {
            mStopwatch.Start();
        }

        public double TickTime
        {
            get
            {
                return mStopwatch.ElapsedMilliseconds;
            }
        }

        class Stopwatch : IStopwatch
        {
            private double mStart;

            public double ElapsedTicks { get; private set; }

            public void Start()
            {
                mStart = mStopwatch.ElapsedMilliseconds;
            }

            public void Stop()
            {
                ElapsedTicks = mStopwatch.ElapsedMilliseconds - mStart;
            }
        }

        public IStopwatch CreateStopwatch()
        {
            return new Stopwatch();
        }
    }
}
